<?php


namespace app\common\model;


use think\Model;
use think\Request;

class Post extends Model
{
    // 表名
    protected $name = 'post';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = '';
    // 追加属性
    protected $append = [
    ];

    public function getAvatarAttr($value, $data)
    {
        $request = Request::instance();
        $domain=$request->domain();
        return $domain.$value;
    }

    public function getImageAttr($value, $data)
    {
        $request = Request::instance();
        $domain=$request->domain();
        return $domain.$value;
    }

    public function user()
    {
        return $this->belongsTo("User", 'user_id', 'id')->setEagerlyType(0);
    }
}